
const jwt = require('jsonwebtoken');
const { tk } = require('../conf/index')



// 设置token  传参是个对象
module.exports = {
    add(data) {
        let token = jwt.sign(
            data,
            tk.secret,
            tk.time
        )
        return token
    },
    check(data) {
        return jwt.verify(data, tk.secret, (error, decoded) => {
            if (error) {
                
                return false
            }
            return decoded
        })
    }
}


